#ifndef __ATCH_UDP__
#define __ATCH_UDP__
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/errno.h>
typedef struct _SocketUdpServer
{
    int16_t port;
    pthread_t serverListenThread;
    struct sockaddr_in serverAddr;
    struct sockaddr_in clientAddr;
    socklen_t serverAddrLen;
    socklen_t clientAddrLen;

    int serverfd;
    char buffer[1024];
    void (*udpServerReceiveAction)(struct _SocketUdpServer *);
} SocketUdpServer;

void destroy_udp_server(SocketUdpServer **sus);
void *udp_server_listen(void *parameter);
SocketUdpServer *create_udp_server(int port, void (*susra)(SocketUdpServer *));

typedef struct _SocketUdpClient
{
    int32_t ip;
    int16_t port;
    struct sockaddr_in serverAddr;
    socklen_t serverAddrLen;
    int clientfd;
    char buffer[1024];
    void (*udpClinentReceiveAction)(struct _SocketUdpClient *);
} SocketUdpClient;

#endif